package com.wallet.controller;

import java.util.HashMap;
import java.util.Map;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wallet.entity.User;
import com.wallet.entity.form.UserForm;
import com.wallet.entity.result.JsonResult;
import com.wallet.entity.result.ResultCode;

@RestController
@RequestMapping("/user")
public class UserController {
	
	@RequestMapping("/login")
    public JsonResult login(@RequestBody User user){

        System.out.println(user.getUsername());
        System.out.println(user.getPassword());

        JsonResult result=new JsonResult();
        Map<String,String> data=new HashMap<String,String>();
        data.put("token","admin-token");
        result.setCode(ResultCode.SUCCESS.getVal());
        result.setData(data);
        return result;
    }
	
	@RequestMapping("/info")
	public JsonResult getInfo(String token) {
		JsonResult result=new JsonResult();
		result.setCode(ResultCode.SUCCESS.getVal());
		UserForm userForm=new UserForm();
		userForm.setName("Super Admin");
		userForm.setAvatar("https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
		userForm.setIntroduction("I am a supper administrator");
		String []roles= {"admin"};
		userForm.setRoles(roles);
		result.setData(userForm);
		return result;
	}

}
